<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true">
      <el-form-item label="登录ip" prop="ipaddr">
        <el-input v-model="queryParams.ipaddr" placeholder="请输入与登录地址" clearable size="small" @keyup.enter.native="handleQuery"></el-input>
      </el-form-item>
      <el-form-item label="用户名称" prop="userName">
        <el-input v-model="queryParams.userName" placeholder="请输入用户名称" clearable size="small" @keyup.enter.native="handleQuery"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button  icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="list" style="width: 100%;">
      <el-table-column label="序号" type="index" align="center">
      </el-table-column>
      <el-table-column label="回话编号" align="center" prop="uuid" :show-overflow-tooltip="true"/>
      <el-table-column label="用户名称" align="center" prop="userName" :show-overflow-tooltip="true"/>
      <el-table-column label="主机ip" align="center" prop="ip" :show-overflow-tooltip="true"/>
      <el-table-column label="浏览器" align="center" prop="explorer" :show-overflow-tooltip="true"/>
      <el-table-column label="操作系统" align="center" prop="os" />
      <el-table-column label="创建时间" align="center" prop="loginTime" width="180px">
        <template slot-scope="scope">
          <span>{{moment(parseInt(scope.row.createTime) * 1000).format('YYYY-MM-DD HH:mm:ss')}}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleForceLogout(scope.row)">强退</el-button>
        </template>
      </el-table-column>
      </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList"></pagination>
  </div>
</template>

<script>
import {list} from '../../../../../api/system/monitor/online'

export default {
  name: 'index',
  data () {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 表格数据
      list: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userName: undefined,
        ipadrr: undefined
      }
    }
  },
  created () {
    this.getList()
  },
  methods: {
    // 查询登录日志列表
    getList () {
      this.loading = true
      list(this.queryParams).then(response => {
        this.list = response.data.list
        this.total = response.data.total
        this.loading = false
      })
    },
    handleQuery () {
      console.log()
    },
    resetQuery () {
      console.log()
    },
    handleForceLogout () {
      console.log()
    }
  }
}
</script>

<style scoped>

</style>
